Switch core catalog to ncruces/go-sqlite3 - #4542
Merged
Merged
Conversation
The analysis core was the last user of modernc.org/sqlite; every other
SQLite path (vet, the sqlite engine analyzer, sqlite3ext, sqltest)
already uses ncruces/go-sqlite3, which as of v0.35 is wasm2go-generated
pure Go with no wazero runtime. Using one driver drops the entire
modernc dependency tree and the second embedded copy of SQLite.
Serialization goes through the driver's Raw() escape hatch and
ext/serdes instead of modernc's Serialize method.
ncruces compiles SQLite with SQLITE_DEFAULT_FOREIGN_KEYS=1, unlike
stock SQLite and modernc. Enforcement surfaced a dangling
return_type_oid in the dolphin seed (UNHEX declares no return type), so
the catalog now pins foreign_keys=OFF explicitly, preserving the
previous behavior where the schema's foreign keys are documentation.
Benchmarks (internal/core/analyzer, n=10, benchstat) show ncruces
slower than modernc on this workload:
CatalogNew 2.625m ± 3% 2.767m ± 3% +5.39% (p=0.000)
ApplySchema 2.953m ± 3% 3.212m ± 7% +8.76% (p=0.000)
Prepare 315.0µ ± 1% 359.6µ ± 8% +14.15% (p=0.000)
geomean 1.347m 1.473m +9.38%
Allocations drop ~3.4% but CPU time is up across the board, trading
single-digit analysis overhead for a single SQLite implementation.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J3BkQjNzN54dXhs3M1ypGr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The analysis core was the last user of
modernc.org/sqlite; every other SQLite path (vet, the sqlite engine analyzer,sqlite3ext,sqltest) already usesncruces/go-sqlite3, which as of v0.35 is wasm2go-generated pure Go with no wazero runtime. Switching the core catalog over leaves a single SQLite implementation in the binary and drops the entire modernc dependency tree (9 go.mod lines, 45 go.sum lines).internal/core/catalog.go: driver import and name (sqlite→sqlite3); both DSN forms (:memory:andfile:...?mode=ro&immutable=1) carry over unchanged.internal/core/cache.go: catalog serialization goes through the driver'sRaw()escape hatch andext/serdesinstead of modernc'sSerializemethod.Foreign keys
ncruces compiles SQLite with
SQLITE_DEFAULT_FOREIGN_KEYS=1, unlike stock SQLite and modernc. Silent enforcement broke MySQL dialect seeding:UNHEXininternal/engine/dolphin/dialect/functions.jsonldeclares"returns": "", leaving a danglingsql_proc.return_type_oidthat modernc never checked. The catalog now pinsPRAGMA foreign_keys = OFFexplicitly, preserving the previous semantics where the schema's foreign keys are documentation. The dangling seed record itself is left for a follow-up, along with an FK-enabled audit of the other dialect seeds.Benchmarks
internal/core/analyzerbenchmarks, n=10, benchstat, linux/amd64 (Xeon 2.10GHz):Allocations drop ~3.4%; CPU time is up across the board. The trade is single-digit analysis overhead for one SQLite implementation instead of two. The catalog cache absorbs the
CatalogNew/ApplySchemacost on warm runs, so the steady-state cost is thePreparedelta.Testing
go test -timeout 20m ./...🤖 Generated with Claude Code
https://claude.ai/code/session_01J3BkQjNzN54dXhs3M1ypGr
Generated by Claude Code